using System;
using AutoMapper;
using CR.Application.DTOs;
using CR.Domain.Entities;

namespace CR.Application.Mappings
{
    /// <summary>
    /// AutoMapper映射配置
    /// </summary>
    public class MappingProfile : Profile
    {
        /// <summary>
        /// 构造函数，配置所有映射关系
        /// </summary>
        public MappingProfile()
        {
            // 溯源管理映射
            CreateMap<TraceabilityManagement, TraceabilityManagementDTO>().ReverseMap();
            CreateMap<TraceabilityCreateDTO, TraceabilityManagement>();
            CreateMap<TraceabilityUpdateDTO, TraceabilityManagement>();
            
            // 添加UpdateDTO到CreateDTO的映射
            CreateMap<TraceabilityUpdateDTO, TraceabilityCreateDTO>();
            
            // 养殖信息映射
            CreateMap<BreedingInfo, BreedingInfoDTO>().ReverseMap();
            
            // 用户映射
            CreateMap<User, UserDTO>()
                .ForMember(dest => dest.PasswordHash, opt => opt.Ignore())
                .ReverseMap();
                
            // 产品检验报告映射
            CreateMap<ProductInspectionReport, ProductInspectionReportDTO>().ReverseMap();
            CreateMap<ProductInspectionReportCreateDTO, ProductInspectionReport>();
        }
    }
} 